package com.zhx.threadcoreknowledge.sixstates;

/**
 * @author ：zhanghaixuan
 * @date ：Created in 2019-10-01 17:10
 * 用途         ： 新建线程的几种状态演示  展示线程 NEW RUNNABLE TERMINATED状态
 * 即时是正在运行,也是Runnable状态 而不是 Running
 */
public class NewRunnableTerminated implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i < 1000; i++) {
            System.out.println(i);
        }
    }

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(new NewRunnableTerminated());
        //这里一定会打印new状态
        System.out.println(thread.getState());
        thread.start();
        System.out.println(thread.getState());
        Thread.sleep(10);
        //打印出runnable  即时是正在运行
        System.out.println(thread.getState());
    }
}
